﻿using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cocos2D;
using Microsoft.Xna.Framework;
using TestTiger.PlayingCard;

namespace TestTiger.Screens
{
    public class TigerScreen : SceneBase
    {
        private PlayingCards leftCards;
        private string[] porkerImgPaths;

        private  readonly CCPoint _leftCardsPt = new CCPoint(100f,240f);

        public override bool Init()
        {
            var layBackground = new CCLayerColor(new CCColor4B(Color.Red));
            AddChild(layBackground);

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("pokers.plist", "pokers");
            porkerImgPaths = new string[53];
            for (var i = 0; i < 53; i++)
            { 
                porkerImgPaths[i] = i == 0 ? "00.png" : i + ".png";
            }
            leftCards = new PlayingCards(porkerImgPaths, _leftCardsPt,new CCSize(79,108));
            leftCards.Position=new CCPoint(300,200);
            AddChild(leftCards); 


            var button = new CCControlButton("kaishi","font",20);
            button.SetPosition(400,240);
            button.OnButtonTap += delegate { leftCards.StartLoop(); };
            AddChild(button);


            //var sp16 = new CCSprite("16.png");
            //sp16.Position = new CCPoint(300, 300);
            //AddChild(sp16);

            //sp16.RunAction(
            //    new CCRepeatForever(CCSpawn.FromActions(new CCJumpBy(1, new CCPoint(0, 0), 100, 1),
            //        new CCRotateBy(1, 30))));

            return base.Init();
        }
    }
}
